`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 2021/07/31 12:57:40
// Design Name: 
// Module Name: lab4_tb
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module lab4_tb();  //testbench module
  reg [9:0] SW;
  reg [3:0] KEY;
  wire [6:0] HEX0;

  lab4_top dut(SW,KEY,HEX0);

  initial begin //total of 28 different tests
     SW=10'b0000000001; KEY=4'b0011; //2
     #10
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000001; KEY=4'b0011;  //2->4 [0100100->0011001] (1 press)
     #30
     SW=10'b0000000001; KEY=4'b0010;  //releasing KEY0 to allow next press to activate properly
     #10

     SW=10'b0000000001; KEY=4'b0011;  //4->0 [0011001->1000000] (2nd press)
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000001; KEY=4'b0011;  //0->3 [1000000->0110000] (3rd press)
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000001; KEY=4'b0011;  //3->1 [0110000->1111001] (4th press)
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000001; KEY=4'b0011;  //1->2 [1111001->0100100] (5th press, 1 full cycle)
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000001; KEY=4'b0011;  //2->4 [0100100->0011001] (cycle continues)
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000001; KEY=4'b0001;  //resetting (4->2 in this case) [0011001->0100100]
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //changes direction, 2->1 [0100100->1111001]
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //1->3 [1111001->0110000]
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //3->0 [0110000->1000000]
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //0->4 [1000000->0011001]
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //4->2 [0011001->0100100]
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //2->1 [0100100->1111001]
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //1->3 [1111001->0110000]
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0001;  //resetting while in reverse (3->2 in this case)
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b1110;  //testing what happens if another key is pressed (should have no affect)
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0111;  //2->1  testing Key0,1,2 at the same time (should still work regardless)
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000001; KEY=4'b0011;  //changes direction, 1->2
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000000; KEY=4'b0011;  //checking that direction change works each time (2->1)
     #30
     SW=10'b0000000000; KEY=4'b0010;
     #10

     SW=10'b0000000011; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000000111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000001111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000011111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0000111111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0001111111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0011111111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b0111111111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10

     SW=10'b1111111111; KEY=4'b0011;  //checking that altering other switches has no effect
     #30
     SW=10'b0000000001; KEY=4'b0010;
     #10
     $display("Tests are finished.");
  end
endmodule
